/**
  * Created by Joshua Conero(O'Uymas) on 2016/10/21 0021.
  * QQ: 957376074
  * E-mail: Brximl@163.com
  * Scala学习语言调试类
  */
import java.util.Date
class Learn() {
  // 构造函数 begin
  val helper = new Helper
  run()
  // 构造函数 end
  def run():Unit = {
    val start = helper.detMsec(0)
    test()
    println(helper.sysdate())
    println(start,helper.detMsec(start),"时间差计算")
    //run_hack()
  }
  // Scala 入门语法测试
  def test():Unit = {
    println("Hello world")
    val x = 0
    println(x+50)
    //var i = 1
    var sum = 0
    val sprt = (n:Int) => n*n
    for(i <- 1 to 10){
      sum = sum+i+sprt(sum)
    }
    println(sprt(8),sum)
    println(scala.math.floor(8.45704),"调试math对象")
    val myXml = <hyang>
      <title>Scala的 XML模式</title>
    </hyang>
    println(myXml)
    val abt = new About()
    println(abt.getName(),abt.getVersion())
    val d = new Date
    println(d.getTime().toString())
  }

  def run_hack():Unit = {
    var url = ""
    url = "http://168.168.168.135/chart/"
    println(url)
    hack(10000,url)
    while(2>5){
      hack(10000,url)
    }
  }
  def hack(ctt:Int,url:String):Unit = {
    val c = new Crawler(url)
    println(url,"hack")
    if(url == "") return
    for(i <- 1 to ctt){
      println(url,"hack+")
      c.getBody(url)
    }
    println("此次认为访问",url,"的十次是：",ctt)
  }
}
